﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RealtyManagementSystem.DAL;

namespace RealtyManagementSystem.Web.RealtyManagers
{
    public partial class RepairIssueManage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
        }

        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "alter")
            {
                int index = Convert.ToInt32(e.CommandArgument);
                GridViewRow row = GridView1.Rows[index];
                var rId = Convert.ToInt32(row.Cells[0].Text);
                using (var contxt = new realtydbEntities())
                {
                    var rep = (from r in contxt.RepairIssues
                               where r.RepairRecordId == rId
                               select r).First();
                    rep.StatusId = 2;
                    contxt.SaveChanges();
                }
            }
            GridView1.DataBind();
        }
    }//class
}